// 高阶函数

/**
 * 防抖
 * @param {Function} fn
 * @param {number} delay
 * @returns
 */
export function debounce(fn, delay = 400) {
  let timer = null;
  return function (...args) {
    if (timer) clearTimeout(timer);
    timer = setTimeout(() => {
      fn.apply(this, args);
    }, delay);
  };
}
